package huoye.shops.huoye.operation.presenter;


import huoye.shops.base.BasePresenter;
import huoye.shops.base.MineBaseJsonRequestCallback;
import huoye.shops.base.UserManager;
import huoye.shops.huoye.operation.model.ObtainShopType;
import huoye.shops.huoye.operation.model.SharePondData;
import huoye.shops.huoye.operation.networt.OperationService;
import huoye.shops.huoye.operation.view.IBangBoBlackCardView;
import huoye.shops.huoye.operation.view.ISharePondView;


/**
 * Created by uesr on 2017/7/19.
 */

public class BangBoBlackCardPresenter extends BasePresenter<IBangBoBlackCardView>  {


    private OperationService mService;



  /*  // 获取商家当前类型等信息
    public void getObtainShopType(){
        // view.showProcessingIndicator();
        mService.getObtainShopType(new MineBaseJsonRequestCallback<ObtainShopType>(ObtainShopType.class) {

            @Override
            public void onSuccess(ObtainShopType obtainShopType) {
                super.onSuccess(obtainShopType);
                view.getShopType(obtainShopType);
            }

            //网络请求失败
            @Override
            public void onFailure(String msg, String code, Throwable e) {
                super.onFailure(msg, code, e);
                view.makeToast(msg);
            }

            //加载结束
            @Override
            public void onNetworkFail() {
                super.onNetworkFail();
                view.onNetworkFail();
            }

            //加载中
            @Override
            public void onFinish() {
                super.onFinish();
                view.hideProcessingIndicator();
            }
        });
    }
*/







   // 加入商家联盟/一卡通
    public void JoinShopCardType(String cardType,String discount){
        if(cardType.equals("1")){
            if(discount.equals("")){
                view.makeToast("请输入折扣额度");
                return;
            }
        }
        mService.JoinShopCardType(cardType,discount,new MineBaseJsonRequestCallback<SharePondData>(SharePondData.class) {

            @Override
            public void onSuccess(SharePondData sharePondData) {
                super.onSuccess(sharePondData);
                if(cardType.equals("1")){
                    UserManager.getInstance().saveCardType(1);
                    view.makeToast("加入帮播联盟商家成功");
                    view.finish();
                }else {
                    UserManager.getInstance().saveCardType(2);
                    view.makeToast("加入帮播黑卡成功");
                    view.getShopType();
                }



            }

            //网络请求失败
            @Override
            public void onFailure(String msg, String code, Throwable e) {
                super.onFailure(msg, code, e);
                view.makeToast(msg);
            }

            //加载结束
            @Override
            public void onNetworkFail() {
                super.onNetworkFail();
                view.onNetworkFail();
            }

            //加载中
            @Override
            public void onFinish() {
                super.onFinish();
                view.hideProcessingIndicator();
            }
        });
    }


    @Override
    public void onStart() {
        mService = new OperationService();
    }
}
